package com.lxw.hi_mvp_mvvm.scene3_mvvm_jectpack;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;

import com.lxw.hi_mvp_mvvm.R;
import com.lxw.hi_mvp_mvvm.User;
import com.lxw.hi_mvp_mvvm.databinding.ActivityScene3Binding;

/**
 * @authour
 * @function
 * @date 2021/4/16
 */
public class scene3Activity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityScene3Binding binding = DataBindingUtil.setContentView(this, R.layout.activity_scene3);
        ViewModelProvider provider =
                new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory());

        HomeViewModel model = provider.get(HomeViewModel.class);

        model.getUserInfo().observe(this, new Observer<User>() {
            @Override
            public void onChanged(User user) {
                binding.setUser(user);
            }
        });
    }
}
